const bgm = uni.createInnerAudioContext();
import httpResUrl from './config.js';
console.log('===httpResUrl===:', httpResUrl)
// bgm.src = httpResUrl.base_res_url+'/audio/dybgm.mp3'
bgm.src = 'https://www.afbeijing.net/static_resources/audio/dybgm-new.mp3'
bgm.loop = true;

var music = {
  //mute 表示是否是静音，，默认不静音
  playBgm ({ mute = false }) {
    if (!bgm) return;
    if (mute) {
      bgm.pause()
    } else {
      bgm.play()
    }

    bgm.onPause(() => {
      console.log('暂停背景音乐');
    })
    bgm.onPlay(() => {
      console.log('开始播放音乐#######');
    })
    bgm.onError((res) => {
      console.log(res)
    })
  }
}
module.exports = music